package com.hotel.dao;



import com.hotel.bean.Room;
import com.hotel.utils.BaseDao;


import java.util.List;

public class RoomDao extends BaseDao<Room> {
    //添加客房
    public int add(Room room){
        String sql = "INSERT INTO room(rname,price,type,state,mark)VALUES(?,?,?,?,?)";
        return adu(sql,room.getRname(),room.getPrice(),room.getType(),room.getState(),room.getMark());
    }
    //查询所有
    public List<Room> selectAll(){
        String sql = "select * from room";
        return queryAll(sql,Room.class);
    }
    //通过id查询
    public Room selectById(int rid){
        String sql = "select * from room where rid = ?";
        return queryOne(sql,Room.class,rid);

    }
    //通过id删除
    public int deleteById(int rid){
        String sql = "delete from room where rid=?";
        return adu(sql,rid);
    }
    //修改客房
    public int updateRoom(Room room){
        String sql = "UPDATE room SET rname=?,price=?,TYPE=?,state=?,mark=? WHERE rid = ?";
        return adu(sql,room.getRname(),room.getPrice(),room.getType(),room.getState(),room.getMark(),room.getRid());
    }
}
